package sprinklerbee.utils;

import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class Location {

	public Location(JFrame frame) {
		int appWidth = frame.getWidth();
		int appHeight = frame.getHeight();
		Toolkit kit = Toolkit.getDefaultToolkit();
		Dimension screenSize = kit.getScreenSize();
		int screenWidth = screenSize.width;
		int screenHeight = screenSize.height;
		frame.setLocation((screenWidth - appWidth) / 2,
				(screenHeight - appHeight) / 2);

	}

	public Location(JDialog dialog) {
		int appWidth = dialog.getWidth();
		int appHeight = dialog.getHeight();
		Toolkit kit = Toolkit.getDefaultToolkit();
		Dimension screenSize = kit.getScreenSize();
		int screenWidth = screenSize.width;
		int screenHeight = screenSize.height;
		dialog.setLocation((screenWidth - appWidth) / 2,
				(screenHeight - appHeight) / 2);

	}

	public Location(JPanel panel) {
		int appWidth = panel.getWidth();
		int appHeight = panel.getHeight();
		Toolkit kit = Toolkit.getDefaultToolkit();
		Dimension screenSize = kit.getScreenSize();
		int screenWidth = screenSize.width;
		int screenHeight = screenSize.height;
		panel.setLocation((screenWidth - appWidth) / 2,
				(screenHeight - appHeight) / 2);

	}
}
